package hui.zhang.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hui.zhang.dao.base.StandardRepository;
import hui.zhang.domain.base.Standard;
import hui.zhang.service.base.StandardService;

/**
 * 收派业务层实现
 * 
 * @author hui.zhang
 * @date 2017年12月9日 下午6:56:33
 */
@Service
@Transactional
public class StandardServiceImpl implements StandardService {

	// dao注入
	@Autowired
	private StandardRepository standardRepository;

	/**
	 * 增 改
	 */
	@Override
	@CacheEvict(value = "standard", allEntries = true)
	public void save(Standard standard) {
		standardRepository.save(standard);
	}

	/**
	 * 分页
	 */
	@Override
	@Cacheable(value="standard",key="#pageable.pageNumber+'_'+#pageable.pageSize")
	public Page<Standard> findAllByPage(Pageable pageable) {
		Page<Standard> page = standardRepository.findAll(pageable);
		return page;
	}

	/**
	 * 查询所有
	 */
	@Cacheable("standard")
	public List<Standard> findAll() {
		List<Standard> list = standardRepository.findAll();
		return list;
	}

}
